/*
 * GraphicsUpdate.cpp
 *	implementation
 *  Created on: 17 Oct 2012
 *      Author: pigmal
 */

#include"GraphicsUpdate.h"
#include <conprint.h>

GraphicsUpdate::GraphicsUpdate()
{
	MAUtil::Environment::getEnvironment().addTimer(this, GRAPHICS_UPDATE_TIME, 0);
}

GraphicsUpdate::~GraphicsUpdate()
{
	ObjectsList.clear();
}

bool GraphicsUpdate::AddComponent(GraphicsComponent *component)
{
	MAUtil::Map<int, GraphicsComponent*>::Iterator it = ObjectsList.find((int)component);
	if(it != ObjectsList.end())
	{
		ObjectsList[(int)component] = component;
	}
	else
	{
		lprintfln(" >> ERROR << GraphicsUpdate::AddComponent - obj already in the list!");
		return false;
	}

	return true;
}

void GraphicsUpdate::RemoveComponent(GraphicsComponent *component)
{
	MAUtil::Map<int, GraphicsComponent*>::Iterator it = ObjectsList.find((int)component);
	if(it != ObjectsList.end())
	{
		ObjectsList.erase(it);
	}
}
